package mysql

import (
	"gorm.io/gorm"
	"mouth-project/global"
)

//用户表

type User struct {
	gorm.Model
	Username string `gorm:"type:varchar(30);not null;comment:用户名"`
	Password string `gorm:"type:char(32);not null;comment:密码"`
	Mobile   string `gorm:"type:char(11);not null;comment:手机号"`
}

//用户注册

func (u *User) Register() error {
	return global.Db.Create(&u).Error
}

//用户登录

func (u *User) Login() error {
	return global.Db.Where("mobile = ?", u.Mobile).Find(&u).Limit(1).Error
}
